﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;

namespace UIElements.Service
{
    public static class VSService
    {
        public static Project GetActiveProject(DTE dte)
        {
            Project activeProject = null;

            Array activeSolutionProjects = dte.ActiveSolutionProjects as Array;
            if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
            {
                activeProject = activeSolutionProjects.GetValue(0) as Project;
            }

            return activeProject;
        }

        public static void WriteToOutputWindow(EnvDTE.DTE dte, string message)
        {
            // dte.ActiveWindow.AutoHides = true;
            var window = dte.Windows.Item(EnvDTEConstants.vsWindowKindOutput);
            var outputWindow = window.Object as EnvDTE.OutputWindow;
            OutputWindowPane outputWindowPane;
            outputWindowPane = outputWindow.OutputWindowPanes.Add("PatternManagementExtension");
            window.Activate();
            outputWindowPane.Activate();
            outputWindowPane.OutputString(message);
        }
    }
}
